package com.itheima.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.domian.User;
import com.itheima.mapper.UserMapper;
import com.itheima.service.UserService;
import entity.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    //通过User的用户账号和用户密码查询用户信息
    @Override
    public User login(User user) {
        return userMapper.login(user);
    }

    @Override
    public PageResult selectAllUser(Integer pageNum,Integer pageSize){
        PageHelper.startPage(pageNum, pageSize);
        Page<User> page=userMapper.selectAllUser();
        return new PageResult(page.getTotal(),page.getResult());
    }
    @Override
    public void addUser(User user){
        userMapper.addUser(user);
    }
    @Override
    public void updateUser(User user){
        userMapper.updateUser(user);
    }
    @Override
    public void deleteUser(User user){
        userMapper.deleteUser(user);
    }
}
